package com.ruoyi.web.vencontact.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.utils.ManualPagination;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.vencontact.domain.VenContact;
import com.ruoyi.web.vencontact.service.IVenContactService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * vencontactController
 * 
 * @author ruoyi
 * @date 2024-09-26
 */
@RestController
@RequestMapping("/vencontact/vencontact")
public class VenContactController extends BaseController
{
    @Autowired
    private IVenContactService venContactService;

    /**
     * 查询vencontact列表
     */
    @PreAuthorize("@ss.hasPermi('vencontact:vencontact:list')")
    @GetMapping("/list")
    public TableDataInfo list(VenContact venContact)
    {
//        startPage();
        List<VenContact> list = venContactService.selectVenContactList(venContact);
        return ManualPagination.pagination(list);
    }

    /**
     * 导出vencontact列表
     */
    @PreAuthorize("@ss.hasPermi('vencontact:vencontact:export')")
    @Log(title = "vencontact", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VenContact venContact)
    {
        List<VenContact> list = venContactService.selectVenContactList(venContact);
        ExcelUtil<VenContact> util = new ExcelUtil<VenContact>(VenContact.class);
        util.exportExcel(response, list, "vencontact数据");
    }

    /**
     * 获取vencontact详细信息
     */
    @PreAuthorize("@ss.hasPermi('vencontact:vencontact:query')")
    @GetMapping(value = "/{OID}")
    public AjaxResult getInfo(@PathVariable("OID") String OID)
    {
        return success(venContactService.selectVenContactByOID(OID));
    }

    /**
     * 新增vencontact
     */
    @PreAuthorize("@ss.hasPermi('vencontact:vencontact:add')")
    @Log(title = "vencontact", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VenContact venContact)
    {
        return toAjax(venContactService.insertVenContact(venContact));
    }

    /**
     * 修改vencontact
     */
    @PreAuthorize("@ss.hasPermi('vencontact:vencontact:edit')")
    @Log(title = "vencontact", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VenContact venContact)
    {
        return toAjax(venContactService.updateVenContact(venContact));
    }

    /**
     * 删除vencontact
     */
    @PreAuthorize("@ss.hasPermi('vencontact:vencontact:remove')")
    @Log(title = "vencontact", businessType = BusinessType.DELETE)
	@DeleteMapping("/{OIDs}")
    public AjaxResult remove(@PathVariable String[] OIDs)
    {
        return toAjax(venContactService.deleteVenContactByOIDs(OIDs));
    }
}
